package com.itheim.array;

import java.util.Scanner;

/*
  评委打分
 */
public class ArrayDemo06 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //定义一个数组以接收评委打的分数
        int arr[] = new int[6];
        for (int i = 0; i < 6; i++) {
            System.out.println("请第" + (i + 1) + "位评委打分:");
            int score = sc.nextInt();
            if(score>0&&score<=10) {
                arr[i] = score;
            }else {
                System.out.println("请输入正确的数值!");
                i--;
            }
        }
        int sum = arr[0];
        int max = arr[0];
        int min = arr[0];
        /*
        for (int i = 0; i < 5; i++) {
            if (max < arr[i + 1]) {
                max = arr[i + 1];
            }
        }
        for (int i = 0; i < 5; i++) {
            if (min > arr[i + 1]) {
                min = arr[i + 1];
            }
        }
        for (int i = 0; i < 5; i++) {
            sum += arr[i + 1];
        }
        */
        for (int i = 0; i < 5; i++) {
            if (max < arr[i + 1]) {
                max = arr[i + 1];
            }
            if (min > arr[i + 1]) {
                min = arr[i + 1];
            }
            sum += arr[i + 1];
        }
        int ave = (sum-max-min)/4;
        System.out.println("综合平均分为:"+ave);
    }
}
